﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Text.RegularExpressions;

/// <summary>
/// Summary description for Utils
/// </summary>
public static class Utils
{
    public static byte[] ReadByteArrayFromFile(string fileName)
    {
        byte[] buff = null;

        try
        {
            FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
            BinaryReader br = new BinaryReader(fs);
            long numBytes = new FileInfo(fileName).Length;
            buff = br.ReadBytes((int)numBytes);
        }
        catch (Exception ex) { Console.WriteLine(ex.Message); }

        return buff;
    }

    public static bool MatchesPattern(this string str, string pattern)
    {
        Regex reg = new Regex(pattern, RegexOptions.IgnoreCase);
        return reg.IsMatch(str);
    }
}
